//
//  File.swift
//  FearfulNotification
//
//  Created by 筱鹏 on 2017/9/27.
//  Copyright © 2017年 筱鹏. All rights reserved.
//

import Foundation
import UIKit
import AudioToolbox

#if RELEASE
public func fearfulPrint(_ item: String) {}
#else
public func fearfulPrint(_ item: String) {
    print(item)
}
#endif

//TODO: Time
let OneDayTimeTnterval: Double = 24 * 60 * 60

//TODO: Screen
let ScreenWidth:CGFloat = UIScreen.main.bounds.width
let ScreenHeight:CGFloat = UIScreen.main.bounds.height

//TODO: UserDefaultKey
let BirthdayModelIdKey: String = "BirthdayModelIdKey"

//TODO: 用户震动反馈
let kSystemSoundID_UserFeedback: SystemSoundID = 1520
public func userFeedBackOfVibrate() {
    if #available(iOS 10.0, *) {
        let generator = UIImpactFeedbackGenerator(style: .light)
        generator.prepare()
        generator.impactOccurred()
    } else {
        AudioServicesPlayAlertSound(kSystemSoundID_UserFeedback)
    }
}

//TODO: 页面配置
/**
 * 页面配置 SynthesizeAlertViewController
 */
let TabBarControllers:[[String:String]] = [["controller":"FearfulNotification.BirthdayViewController",
                                            "title"     :"生日",
                                            "image"     :"alertEvent_nor"]]


//TODO: 安全方法
public func safeMainQueueAsync(_ closure: @escaping () -> Void) {
    if Thread.isMainThread {
        closure()
    } else {
        DispatchQueue.main.async {
            closure()
        }
    }
}

public func safeMainQueueSync(_ closure: @escaping () -> Void) {
    if Thread.isMainThread {
        closure()
    } else {
        DispatchQueue.main.sync {
            closure()
        }
    }
}
